<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
	<title>Fancytree - Example: Scrolling</title>

	<script src="//code.jquery.com/jquery-1.12.1.min.js" type="text/javascript"></script>
	<script src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js" type="text/javascript"></script>
	<link href="../src/skin-win8/ui.fancytree.css" rel="stylesheet" type="text/css">

	<script src="../src/jquery.fancytree.js" type="text/javascript"></script>
	<script src="../src/jquery.fancytree.columnview.js" type="text/javascript"></script>
	<script src="../src/jquery.fancytree.dnd.js" type="text/javascript"></script>
	<script src="../src/jquery.fancytree.table.js" type="text/javascript"></script>


	<!-- Start_Exclude: This block is not part of the sample code -->
	<link href="../lib/prettify.css" rel="stylesheet">
	<script src="../lib/prettify.js" type="text/javascript"></script>
	<link href="sample.css" rel="stylesheet" type="text/css">
	<script src="sample.js" type="text/javascript"></script>
	<!-- End_Exclude -->
<style type="text/css">
ul.fancytree-container {
	width: 200px;
	height: 100px;
	overflow: auto;
	position: relative;
}
</style>
	<!-- Add code to initialize the tree when the document is loaded: -->
<script type="text/javascript">
// http://lions-mark.com/jquery/scrollTo/

/*
$.fn.scrollTo = function( target, options, callback ){
	if(typeof options == 'function' && arguments.length == 2){ callback = options; options = target; }
	var settings = $.extend({
		scrollTarget: target,
		offsetTop: 0, //50,
		duration: 500,
		easing: "swing"
	}, options);
	return this.each(function(){
	  var scrollPane = $(this);
	  var scrollTarget = (typeof settings.scrollTarget == "number") ? settings.scrollTarget : $(settings.scrollTarget);
	  var scrollY = (typeof scrollTarget == "number") ? scrollTarget : scrollTarget.offset().top + scrollPane.scrollTop() - parseInt(settings.offsetTop);
	  scrollPane.animate({scrollTop : scrollY }, parseInt(settings.duration), settings.easing, function(){
		  if (typeof callback == 'function') { callback.call(this); }
	  });
	});
  }
  */
	$(function(){
		<!-- Start_Exclude: This block is not part of the sample code -->
		<!-- End_Exclude -->

		// Attach the fancytree widget to an existing <div id="tree"> element
		// and pass the tree options as an argument to the fancytree() function:
		$("#tree").fancytree({
			extensions: [],
			checkbox: true,
			autoScroll: true,
			source: {
				url: "../test/unit/ajax-tree-plain.json"
			},
			lazyLoad: function(event, data) {
				data.result = {url: "../test/unit/ajax-sub2.json"}
			},
			init: function(event, data) {
				data.tree.getFirstChild().setFocus();
			},
			focus: function(event, data){
				data.node.scrollIntoView(true);
			},
			// expand: function(event, data){
			// 	// scroll down to last node, but keep current node visible
			// 	data.node.getLastChild().scrollIntoView(true, {topNode: data.node});
			// }
		});
	});
		</script>
</head>
<body class="example">
	<h1>Example: scrolling</h1>
	<p class="description">
	</p>
	<div>
		<label for="skinswitcher">Skin:</label> <select id="skinswitcher"></select>
	</div>
	<!-- Add a <table> element where the tree should appear: -->
	<p class="description">
		Standard tree:
	</p>
	<div id="tree"></div>

	<!-- Add a <table> element where the tree should appear: -->
	<p class="description">
		Table tree:
	</p>
	<!-- Start_Exclude: This block is not part of the sample code -->
	<hr>
	<p class="sample-links  no_code">
		<a class="hideInsideFS" href="https://github.com/mar10/fancytree">jquery.fancytree.js project home</a>
		<a class="hideOutsideFS" href="#">Link to this page</a>
		<a class="hideInsideFS" href="index.html">Example Browser</a>
		<a href="#" id="codeExample">View source code</a>
	</p>
	<pre id="sourceCode" class="prettyprint" style="display:none"></pre>
	<!-- End_Exclude -->
</body>
</html>
